package com.chengn.queue.property;


import com.chengn.factory.MyThreadFactory;

import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class PropertyQueueMain {

    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(1,
                1,
                1,
                TimeUnit.SECONDS,
                new PriorityBlockingQueue<>(10),
                new MyThreadFactory());


        for (int i = 0; i < 10; ++i) {
            final int finalI = i;
            executor.execute(new MyPropertyRunnable(10 - finalI) {
                @Override
                public void run() {
                    try {
                        TimeUnit.SECONDS.sleep(1);
                    } catch (Exception ex) {
                        // TODO
                    }
                    System.out.println(finalI);
                }
            });
        }
    }
}
